home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 83win / data1.cab / DLL_Toolkit / Source / HTBString / string.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  6.8 KB  |  300 lines

  1. // string.cpp : Defines the initialization routines for the DLL.
  2. //    High Tech BASIC, Copyright (C) TransEra Corp 1999, All Rights Reserved.
  3.  
  4. #include "stdafx.h"
  5. #include "string.h"
  6.  
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. //
  14. //    Note!
  15. //
  16. //        If this DLL is dynamically linked against the MFC
  17. //        DLLs, any functions exported from this DLL which
  18. //        call into MFC must have the AFX_MANAGE_STATE macro
  19. //        added at the very beginning of the function.
  20. //
  21. //        For example:
  22. //
  23. //        extern "C" BOOL PASCAL EXPORT ExportedFunction()
  24. //        {
  25. //            AFX_MANAGE_STATE(AfxGetStaticModuleState());
  26. //            // normal function body here
  27. //        }
  28. //
  29. //        It is very important that this macro appear in each
  30. //        function, prior to any calls into MFC.  This means that
  31. //        it must appear as the first statement within the 
  32. //        function, even before any object variable declarations
  33. //        as their constructors may generate calls into the MFC
  34. //        DLL.
  35. //
  36. //        Please see MFC Technical Notes 33 and 58 for additional
  37. //        details.
  38. //
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CStringApp
  42.  
  43. BEGIN_MESSAGE_MAP(CStringApp, CWinApp)
  44.     //{{AFX_MSG_MAP(CStringApp)
  45.         // NOTE - the ClassWizard will add and remove mapping macros here.
  46.         //    DO NOT EDIT what you see in these blocks of generated code!
  47.     //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CStringApp construction
  52.  
  53. CStringApp::CStringApp()
  54. {
  55.     // TODO: add construction code here,
  56.     // Place all significant initialization in InitInstance
  57. }
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // The one and only CStringApp object
  61.  
  62. CStringApp theApp;
  63.  
  64.  
  65.  
  66. extern "C"
  67. {
  68.  
  69.  
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. /*
  73.     Function:        Append
  74.  
  75.     Description:    append one string to another    
  76.  
  77.     Return type:    char* _cdecl 
  78.     Argument:        char* str1
  79.     Argument:        char* str2
  80.  
  81.     Notes:
  82.         
  83. */
  84. char* _cdecl Append(char* str1, char* str2)
  85. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  86.  
  87.     return(strcat(str1,str2));
  88. }
  89.  
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. /*
  93.     Function:        FindChar
  94.  
  95.     Description:    return pointer to first instance of given character
  96.  
  97.     Return type:    char* _cdecl 
  98.     Argument:        char* str
  99.     Argument:        char c
  100.  
  101.     Notes:
  102.         
  103. */
  104. char* _cdecl FindChar(char* str, char c)
  105. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  106.  
  107.     return(strchr(str,c));
  108. }
  109.  
  110.  
  111. /////////////////////////////////////////////////////////////////////////////
  112. /*
  113.     Function:        CopyString
  114.  
  115.     Description:    copy the contents of one string into another
  116.  
  117.     Return type:    char* _cdecl 
  118.     Argument:        char* str1
  119.     Argument:        char* str2
  120.  
  121.     Notes:
  122.         
  123. */
  124. char* _cdecl CopyString(char* str1, char* str2)
  125. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  126.  
  127.     return(strcpy(str1,str2));
  128. }
  129.  
  130.  
  131. /////////////////////////////////////////////////////////////////////////////
  132. /*
  133.     Function:        FindFromSet
  134.  
  135.     Description:    returns an integer value specifying the length of the initial segment of string
  136.                     that consists entirely of characters not in str2. If string begins with a
  137.                     character that is in str2, the function returns 0.     
  138.  
  139.     Return type:    short _cdecl 
  140.     Argument:        char* str1
  141.     Argument:        char* str2
  142.  
  143.     Notes:
  144.         
  145. */
  146. short _cdecl FindFromSet(char* str1,char* str2)
  147. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  148.  
  149.     return(strcspn(str1,str2));
  150. }
  151.  
  152.  
  153. /////////////////////////////////////////////////////////////////////////////
  154. /*
  155.     Function:        CompareLower
  156.  
  157.     Description:    compares lowercase versions of str1 and str2.
  158.                     if the return is 0 then the strings are the same.  if the return is negative
  159.                     then str1 is less than str2.  if the return is positive then str1 > str2
  160.                     
  161.  
  162.     Return type:    short _cdecl 
  163.     Argument:        char* str1
  164.     Argument:        char* str2
  165.  
  166.     Notes:
  167.         
  168. */
  169. short _cdecl Compare(char* str1,char* str2)
  170. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  171.  
  172.     return(stricmp(str1,str2));
  173. }
  174.  
  175.  
  176. /////////////////////////////////////////////////////////////////////////////
  177. /*
  178.     Function:        AppendCount
  179.  
  180.     Description:    appends first count characters of str2 to the end of str1.
  181.  
  182.     Return type:    char* _cdecl 
  183.     Argument:        char* str1
  184.     Argument:        char* str2
  185.     Argument:        short count
  186.  
  187.     Notes:
  188.         
  189. */
  190. char* _cdecl AppendCount(char* str1,char* str2,short count)
  191. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  192.  
  193.     return(strncat(str1,str2,count));    
  194. }
  195.  
  196.  
  197. /////////////////////////////////////////////////////////////////////////////
  198. /*
  199.     Function:        CopyStringCount
  200.  
  201.     Description:    copies the first count characters of str2 into str1
  202.  
  203.     Return type:    char* _cdecl 
  204.     Argument:        char* str1
  205.     Argument:        char* str2
  206.     Argument:        short count
  207.  
  208.     Notes:
  209.         
  210. */
  211. char* _cdecl CopyStringCount(char* str1,char* str2,short count)
  212. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  213.  
  214.     return(strncpy(str1,str2,count));
  215. }
  216.  
  217.  
  218. /////////////////////////////////////////////////////////////////////////////
  219. /*
  220.     Function:        CompareStringCount
  221.  
  222.     Description:    compares the first count characters of lowercase versions of str1 and str2
  223.                     if the return is 0 then the strings are the same.  if the return is negative
  224.                     then str1 is less than str2.  if the return is positive then str1 > str2
  225.  
  226.     Return type:    short _cdecl 
  227.     Argument:        char* str1
  228.     Argument:        char* str2
  229.     Argument:        short count
  230.  
  231.     Notes:
  232.         
  233. */
  234. short _cdecl CompareStringCount(char* str1,char* str2,short count)
  235. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  236.  
  237.     return(strnicmp(str1,str2,count));
  238. }
  239.  
  240.  
  241. /////////////////////////////////////////////////////////////////////////////
  242. /*
  243.     Function:        GetFromSet
  244.  
  245.     Description:    returns a pointer to the first character in str1 that exists in str2
  246.  
  247.     Return type:    char* _cdecl 
  248.     Argument:        char* str1
  249.     Argument:        char* str2
  250.  
  251.     Notes:
  252.         
  253. */
  254. char* _cdecl GetFromSet(char* str1,char* str2)
  255. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  256.  
  257.     return(strpbrk(str1,str2));
  258. }
  259.  
  260.  
  261. /////////////////////////////////////////////////////////////////////////////
  262. /*
  263.     Function:        Reverse
  264.  
  265.     Description:    reverses the string
  266.  
  267.     Return type:    char* _cdecl 
  268.     Argument:        char* str
  269.  
  270.     Notes:
  271.         
  272. */
  273. char* _cdecl Reverse(char* str)
  274. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  275.  
  276.     return(strrev(str));
  277. }
  278.  
  279.  
  280. /////////////////////////////////////////////////////////////////////////////
  281. /*
  282.     Function:        FindSub
  283.  
  284.     Description:    returns a pointer to the first occurance of str2 in str1
  285.  
  286.     Return type:    char* _cdecl 
  287.     Argument:        char* str1
  288.     Argument:        char* str2
  289.  
  290.     Notes:
  291.         
  292. */
  293. char* _cdecl FindSub(char* str1,char* str2)
  294. {    AFX_MANAGE_STATE(AfxGetStaticModuleState());
  295.  
  296.     return(strstr(str1,str2));
  297. }
  298.  
  299.  
  300. } // end extern "C"